package com.zzc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zzc.common.JsonResult;
import com.zzc.common.TableResult;
import com.zzc.mapper.ApiSystemparamMapper;
import com.zzc.mapper.ApiSystemparamMapper;
import com.zzc.pojo.ApiSystemparam;
import com.zzc.pojo.ApiSystemparam;
import com.zzc.service.AppInfoService;
import com.zzc.service.SystemParatersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhouzhicheng
 * @version 1.0  2020/12/29
 */
@Service
public class SystemParatersServiceImpl implements SystemParatersService {
    @Autowired
    private ApiSystemparamMapper apiSystemparamMapper;
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return 0;
    }

    @Override
    public int insert(ApiSystemparam record) {
        return 0;
    }

    @Override
    public JsonResult insertSelective(ApiSystemparam record) {
        return apiSystemparamMapper.insertSelective(record)>0? JsonResult.getResultSuccess():JsonResult.getResultFailed();
    }

    @Override
    public ApiSystemparam selectByPrimaryKey(Integer id) {
        return null;
    }

    @Override
    public JsonResult updateByPrimaryKeySelective(ApiSystemparam record) {
        return apiSystemparamMapper.updateByPrimaryKeySelective(record)>0?JsonResult.getResultSuccess():JsonResult.getResultFailed();
    }

    @Override
    public int updateByPrimaryKeyWithBLOBs(ApiSystemparam record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(ApiSystemparam record) {
        return 0;
    }

    @Override
    public TableResult getSystemParaters(Integer page,Integer limit,String name, Integer state) {
        //分页设置 当前页和每页大小
        PageHelper.startPage(page,limit);
        //获取分页信息
        PageInfo<ApiSystemparam> pageInfo = new PageInfo<>(apiSystemparamMapper.getSystemParaters(name,state));

        return new TableResult(0,null,Long.valueOf(pageInfo.getTotal()).intValue(),pageInfo.getList());
    }

    @Override
    public JsonResult deleteSystemParatersById(Integer[] ids) {
        return apiSystemparamMapper.deleteById(ids)>0
                ? JsonResult.getResultSuccess()
            : JsonResult.getResultFailed();
    }

    @Override
    public List<ApiSystemparam> getAllSystemParaters() {
        return apiSystemparamMapper.getSystemParaters(null,null);
    }
}
